package com.eistert.java.datastructure._14_AVL;

import com.eistert.java.datastructure._07_Set._07_Set;
import com.eistert.java.util.FileOperation2;

import java.util.ArrayList;

public class _14_TestSetMain {

    private static double testSet(_07_Set<String> a14Set, String filename) {

        long startTime = System.nanoTime();

        System.out.println(filename);
        ArrayList<String> words = new ArrayList<>();
        if (FileOperation2.readFile(filename, words)) {
            System.out.println("Total words: " + words.size());

            for (String word : words)
                a14Set.add(word);
            System.out.println("Total different words: " + a14Set.getSize());
        }

        long endTime = System.nanoTime();

        return (endTime - startTime) / 1000000000.0;
    }

    public static void main(String[] args) {

        String filename = "pride-and-prejudice.txt";

        _14_BSTSet<String> a14BstSet = new _14_BSTSet<>();
        double time1 = testSet(a14BstSet, filename);
        System.out.println("BST Set: " + time1 + " s");

        System.out.println();

        _14_LinkedList14Set<String> a14LinkedListSet = new _14_LinkedList14Set<>();
        double time2 = testSet(a14LinkedListSet, filename);
        System.out.println("Linked List Set: " + time2 + " s");

        System.out.println();

        _14_AVLSet<String> avlSet = new _14_AVLSet<>();
        double time3 = testSet(avlSet, filename);
        System.out.println("AVL Set: " + time3 + " s");
    }
}
